
import { MoveableDialog, createDiv } from "./moveable_dialog";

export class AlertDialog extends MoveableDialog {

    private divTitle: HTMLDivElement;
    private divImage: HTMLDivElement;
    private divMsg: HTMLDivElement;
    
    constructor(title: string, msg: string) {
        super();
        let row = createDiv('', 'dialog_title');
        this.dialog.appendChild(row);
        this.divTitle = createDiv(title);
        row.appendChild( createDiv('', 'dialog_70') );
        row.appendChild( this.divTitle );
        row.appendChild( this.btnClose );
        row = createDiv('', 'flex_row_center', 'mt10');
        this.dialog.appendChild(row);
        this.divImage = createDiv('', 'dialog_err');
        this.divMsg = createDiv(msg, 'ml10', 'dialog_msg');
        row.appendChild(this.divImage);
        row.appendChild(this.divMsg);
        this.show();
    }

    readonly setMsg = (msg: string) => {
        this.divMsg.innerText = msg;
    }

    readonly prog = (msg: string) => {
        this.divMsg.innerText = msg;
        this.divImage.classList.remove(...this.divImage.classList);
        this.divImage.classList.add('dialog_prog');
    }

    readonly success = (msg: string) => {
        this.divMsg.innerText = msg;
        this.divImage.classList.remove(...this.divImage.classList);
        this.divImage.classList.add('dialog_succ');
        this.divImage.style.transform = `rotate(0deg)`;
    }

    readonly warn = (msg: string) => {
        this.divMsg.innerText = msg;
        this.divImage.classList.remove(...this.divImage.classList);
        this.divImage.classList.add('dialog_warn');
        this.divImage.style.transform = `rotate(0deg)`;
    }

    readonly error = (msg: string) => {
        this.divMsg.innerText = msg;
        this.divImage.classList.remove(...this.divImage.classList);
        this.divImage.classList.add('dialog_err');
        this.divImage.style.transform = `rotate(0deg)`;
    }
}



